﻿using Cinch;
using FR.SAFTAnalyser.ViewModels.Workspace;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FR.SAFTAnalyser.Services
{
    public static class OpenFileServiceHelpers
    {
        public static string OpenFile(this IOpenFileService openFileService, string filter)
        {
            if (File.Exists(Workspace.Instance.Config.SAFTFileName))
                openFileService.InitialDirectory = new FileInfo(Workspace.Instance.Config.SAFTFileName).DirectoryName;
            else
                openFileService.InitialDirectory = @"C:\";

                openFileService.Filter = filter;
                var result = openFileService.ShowDialog(null);
                if (result.HasValue && result.Value == true)
                    return openFileService.FileName;
            

            return string.Empty;
        }
    }
}
